package com.hm.common.config;

import com.hm.common.interceptor.AuthInterceptor;
import com.hm.common.interceptor.LimitingInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
* @Description: 拦截器配置
* @param
* @return
* @throws
* @author Coder编程
* @date 2021/6/18 16:01
*/
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private AuthInterceptor authInterceptor;

    @Autowired
    private LimitingInterceptor limitingInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        /*  鉴权拦截器 */
        registry.addInterceptor(authInterceptor).order(1).addPathPatterns("/generateShortUrl", "/batchToShortUrl");
        /*  限流拦截器 */
        registry.addInterceptor(limitingInterceptor).order(2).addPathPatterns("/generateShortUrl", "/batchToShortUrl");
    }



}
